package com.info.game;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.component.game.PhysicsComponent;
import com.engine.game.GameObject;


public class CeilStage1PhysicsComponent implements PhysicsComponent{

	
	
	private Body ceil;
	
	@Override
	public void dispose() {
		
		this.ceil.getWorld().destroyBody(this.ceil);
		
	}

	@Override
	public void bodyCreation(GameObject object) {
		
		
		BodyDef ceilDef = new BodyDef();
		ceilDef.type = BodyType.StaticBody;
		ceilDef.position.set(20, 30);
		
		this.ceil = object.getPhysicsWorld().createBody(ceilDef);
		
		PolygonShape ceilShape = new PolygonShape();
		ceilShape.setAsBox(SizeOfThings.Stage1FloorWidth/2, SizeOfThings.Stage1FloorHeight/2);
		
		
		FixtureDef ceilFix = new FixtureDef();
		ceilFix.shape = ceilShape;
		
		this.ceil.createFixture(ceilFix).setUserData(object.name);;
		
		
		
		this.ceil.setUserData(object);
		
		
		
	}

	@Override
	public void update(GameObject object) throws InstantiationException,
			IllegalAccessException, ClassNotFoundException {
		
		
	}

	
	
	
	
	
	@Override
	public void collisionWith(GameObject me, String enemy) {
		
		
	}

	@Override
	public void endCollisionWith(GameObject me, String enemy) {
		
		
	}

	@Override
	public float getCenterBodyX() {
		
		return this.ceil.getPosition().x;
	}

	@Override
	public float getCenterBodyY() {
		
		return this.ceil.getPosition().y;
	}

	@Override
	public float getBodyAngle() {
		
		return this.ceil.getAngle() * MathUtils.radiansToDegrees;
	}

}
